Skip to content

fix(cli): remove shadowing local json import breaking A2A setup#6345

Open
AnayGarodia wants to merge 2 commits into
google:mainfrom
AnayGarodia:fix-a2a-json-unboundlocal
Open

fix(cli): remove shadowing local json import breaking A2A setup#6345
AnayGarodia wants to merge 2 commits into
google:mainfrom
AnayGarodia:fix-a2a-json-unboundlocal

Conversation

@AnayGarodia

Copy link
Copy Markdown

Fixes #6332

Running adk api_server --a2a (or get_fast_api_app(..., a2a=True)) silently mounts no A2A routes. The gemini_enterprise_app_name block near the end of get_fast_api_app has a redundant function-local import json. Because of that local import, json is a local variable for the entire function, so the earlier json.load(f) in the A2A discovery loop raises UnboundLocalError: cannot access local variable 'json'. That exception is caught by the loop's except Exception, logged as "Failed to setup A2A agent", and swallowed, so every A2A agent silently fails to register and no /a2a/... routes are added.

json is already imported at module scope, so this removes the redundant local import. (The sibling import inspect in that block is kept: inspect is not imported at module scope.)

The existing A2A test only checks /list-apps, so it passed despite the broken route mounting. The added regression test drives get_fast_api_app(a2a=True) over a temp agent directory and asserts the A2A application is actually constructed (i.e. execution gets past the json.load call). It fails on main with the UnboundLocalError path and passes with this change; the existing A2A tests continue to pass.

@google-cla

google-cla Bot commented Jul 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@AnayGarodia

Copy link
Copy Markdown
Author

@googlebot I signed it!

2 similar comments
@AnayGarodia

Copy link
Copy Markdown
Author

@googlebot I signed it!

@AnayGarodia

Copy link
Copy Markdown
Author

@googlebot I signed it!

@rohityan rohityan added a2a [Component] This issue is related a2a support inside ADK. needs review [Status] The PR/issue is awaiting review from the maintainer labels Jul 9, 2026
@rohityan

rohityan commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Hi @AnayGarodia , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan

rohityan commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Hi @wyf7107 , can you please review this. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a2a [Component] This issue is related a2a support inside ADK. needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adk api_server --a2a silently mounts no A2A routes: UnboundLocalError on json in get_fast_api_app

2 participants